<template>
    <div>
        <el-row>
            <el-col :span="24" class="base-mian-cell" v-if="reviewFlag">
                <div class="base-mian-cell-title clearfix">
                    <div class="left fl">
                        <span class="line">|</span>
                        <span class="tips">续核记录</span>
                    </div>
                    <div class="right fr" @click="changeView">
                        <i class="el-icon-circle-close"></i>
                    </div>
                </div>
                <div class="base-mian-cell-main">
                    <el-table
                            :data="renews"
                            style="width: 100%">
                        <el-table-column type="index"
                                         :index="indexMethod" label="序号" min-width="120" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column prop="chdrnum" label="保单号码" min-width="120" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column prop="clmnum" label="受理号码" min-width="120" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column prop="bmntdesc" label="核保意见" min-width="120" show-overflow-tooltip>
                            <template slot-scope="scope">
                                <div class="txt-line" v-if="scope.row.clmnumShow!=''" @click="underwritingOpinion(scope.row.clmnum)">核保意见</div>
                                <div class="txt-line" v-else></div>
                            </template>
                        </el-table-column>
                        <el-table-column prop="trectyp" label="处理状态" min-width="120" show-overflow-tooltip>
                            <template slot-scope="scope">
                                {{scope.row.trectyp | trectypPipe}}
                            </template>
                        </el-table-column>
                        <el-table-column prop="mind" label="续核结论" min-width="120" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column prop="crtable" label="险种" min-width="120" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column prop="notedesc01Show" label="加费原因" min-width="120" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column prop="notedesc02Show" label="除外原因" min-width="120" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column prop="notedesc04Show" label="不予续保原因" min-width="120" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column prop="declnrsnShow" label="批注原因" min-width="120" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column prop="pedescShow" label="批注内容" min-width="120" show-overflow-tooltip>
                        </el-table-column>
                        <el-table-column prop="chdrnum" label="旧版核保意见" min-width="120" show-overflow-tooltip>
                            <template slot-scope="scope">
                                <div class="txt-line" v-if="scope.row.chdrnumShow!=''" @click="showOldDesc(scope.row.chdrnum)">旧版核保意见</div>
                                <div class="txt-line" v-else></div>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
            </el-col>
        </el-row>
        <el-row>
            <el-col :span="24">
                <div class="pagination">
                    <el-pagination
                            background
                            v-if='paginations.total > 0'
                            :page-sizes="paginations.pageSizes"
                            :page-size="paginations.pageSize"
                            :layout="paginations.layout"
                            :total="paginations.total"
                            :current-page='paginations.pageIndex'
                            @current-change='handleCurrentChange'
                            @size-change='handleSizeChange'>
                    </el-pagination>
                </div>
            </el-col>
        </el-row>

        <!-- 核保意见弹框 -->
        <el-dialog
                title="核保意见"
                :visible.sync="opinionDialogVisible"
                width="60%"
                center>
            <el-table :data="opinionData" @row-click="showBmntdesc">
                <el-table-column type="index"
                                 :index="indexMethod" label="序号" min-width="120" show-overflow-tooltip></el-table-column>
                <el-table-column property="bmntdesc" label="核保意见" min-width="200" show-overflow-tooltip></el-table-column>
                <el-table-column property="effdate" label="日期" min-width="160" show-overflow-tooltip></el-table-column>
                <el-table-column property="userProfile" label="用户" min-width="120" show-overflow-tooltip></el-table-column>
            </el-table>
            <!--            <span class="tips" v-if="isShowBmntdesc">点击列表中核保意见可在下方文本域中展示详细核保意见信息：</span>-->
            <!--            <el-input v-model="bmntdesc" v-if="isShowBmntdesc"-->
            <!--                      type="textarea"-->
            <!--                      :rows="2"-->
            <!--            >-->
            <!--            </el-input>-->
            <span slot="footer" class="dialog-footer">
            <el-button @click="opinionDialogVisible = false">返 回</el-button>
        </span>
        </el-dialog>


        <!-- 旧版核保意见弹框 -->
        <el-dialog
                title="旧版核保意见"
                :visible.sync="opinionDialogVisible1"
                width="60%"
                center>
            <el-table :data="opinionData1">
                <el-table-column type="index"
                                 :index="indexMethod" label="序号" min-width="120" show-overflow-tooltip></el-table-column>
                <el-table-column property="flag01" label="类别" min-width="120" show-overflow-tooltip></el-table-column>
                <el-table-column property="chdrnum" label="保单号码" min-width="120" show-overflow-tooltip></el-table-column>
                <el-table-column property="cmntcde" label="代码" min-width="120" show-overflow-tooltip></el-table-column>
                <el-table-column property="cmntdesc" label="说明" min-width="200" show-overflow-tooltip></el-table-column>
                <el-table-column property="crtuser" label="核保人员" min-width="120" show-overflow-tooltip></el-table-column>
                <el-table-column property="crtdate" label="操作日期" min-width="160" show-overflow-tooltip></el-table-column>
            </el-table>
            <!--            <span class="tips" v-if="isShowBmntdesc">点击列表中核保意见可在下方文本域中展示详细核保意见信息：</span>-->
            <!--            <el-input v-model="bmntdesc" v-if="isShowBmntdesc"-->
            <!--                      type="textarea"-->
            <!--                      :rows="2"-->
            <!--            >-->
            <!--            </el-input>-->
            <span slot="footer" class="dialog-footer">
            <el-button @click="opinionDialogVisible1 = false">返 回</el-button>
        </span>
        </el-dialog>

    </div>
</template>
<script>
  import {trectypPipe} from '@/pipe/comPipe';
  import {
    contiNucleNoteHistoryBmntdesc,
    findOldBmntdescByChdrnum
  } from "@/api/underwriting/uw";
  import {
    findContiNucleNoteHistory
  } from "@/api/underwriting/renewal";
  import constant from '@/utils/constant';

  export default {
    data() {
      return {
        opinionDialogVisible: false,
        opinionDialogVisible1: false,
        opinionData: [],
        opinionData1: [],
        bmntdesc: "",
        renews:[],
        paginations: {
          total: 0,        // 总数
          pageIndex: 1,  // 当前位于哪页
          pageSize: 10,   // 1页显示多少条
          pageSizes: [5, 10, 15, 20],  //每页显示多少条
          layout: "total, sizes, prev, pager, next, jumper"   // 翻页属性
        },
      }
    },
    props: {
      reviewFlag: {
        type: Boolean,
        default: false
      },
      clntnum:{
        type:String,
        default:""
      }
      // renews: {
      //   type: Array,
      //   default() {
      //     return [];
      //   }
      // }
    },
    methods: {
      changeView() {
        this.$emit('subReviewFlag', false);
      },
      indexMethod(index) {
        return index + 1;
      },
      showBmntdesc(row, column, event) {
        this.bmntdesc = row.bmntdesc;
      },
      //核保意见
      underwritingOpinion(clmnum) {
        let that = this;
        let params = {
          "aplnum": clmnum
        }
        that.$emit('showLoading',true);
        contiNucleNoteHistoryBmntdesc(params).then(res => {
          that.$emit('showLoading',false);
          if (res.resultCode == constant.SUCCESS && res.data != null) {
            that.opinionData = res.data;
          }
        }).catch(err => {
          console.log(err)
        })
        this.opinionDialogVisible = true;
      },

      //旧版核保意见
      showOldDesc(chdrnum) {
        let that = this;
        let params = {
          "chdrnum":chdrnum
        }
        that.$emit('showLoading',true);
        findOldBmntdescByChdrnum(params).then(res=>{
          that.$emit('showLoading',false);
          if (res.resultCode == constant.SUCCESS && res.data != null) {
            that.opinionData1 = res.data;
          }
        }).catch(err=>{
          console.log(err)
        })
        this.opinionDialogVisible1 = true;
      },
      handleCurrentChange(page) {
        this.paginations.pageIndex = page;
        this.search();
      },
      // 照会代码弹框切换每页数据大小
      handleSizeChange() {
        this.paginations.pageSize = pageSize;
        this.search();
      },
      search(){
        let that = this;
        debugger
        let params = {
          "pageSize": this.paginations.pageSize,
          "pageNumber": this.paginations.pageIndex,
          "clntnum": this.clntnum
        }
        that.$emit('showLoading',true);
        findContiNucleNoteHistory(params).then(res => {
          that.$emit('showLoading',false);
          if (res.resultCode == constant.SUCCESS && res.data != null) {
            that.renews = res.data.list;
            that.paginations.total = res.data.total
          }
        }).catch(err => {
        })
      }
    },
    created() {
      this.search();
    },
    filters:{
      trectypPipe:function (value) {
        return trectypPipe(value);
      }
    }
  }
</script>
<style lang="less" scoped>
    .txt-line {
        color: #68A3FC;
        text-decoration: underline;
        cursor: pointer;
    }
</style>